import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;

/**
 * The Class VendingMachineItemTest used to test the VendingMachineItem class.
 * @author Archana
 *
 */
public class VendingMachineItemTest {

	/**
     * Test method for VendingMachineItem(java.lang.String, double).
     * Tests the constructor when the price >= zero.
     */
    @Test
    public void tstVendingMachineItem_PriceAboveZero()
    {
            VendingMachineItem tstVendingMachine = new VendingMachineItem("Item1", 2.50);
            assertEquals("Item1", tstVendingMachine.getName());
            assertEquals(2.50, tstVendingMachine.getPrice(), 0.001);
    }



    /**
     * Test method for VendingMachineItem(java.lang.String, double).
     * Tests the constructor when the price < zero.
     */
    @Test(expected = VendingMachineException.class)
    public void tstVendingMachineItem_PriceBelowZero()
    {
            VendingMachineItem tstVendingMachine = new VendingMachineItem("Item1", -2.50);
    }



    /**
     * Test method for VendingMachineItem(java.lang.String, double).
     * Tests the constructor when the name is an empty string.
     */
    @Test(expected = VendingMachineException.class)
    public void tstVendingMachineItem_NameEmpty()
    {
            VendingMachineItem tstVendingMachine = new VendingMachineItem("", 2.50);
    }



    /**
     * Test method for VendingMachineItem(java.lang.String, double)}.
     * Tests the constructor when the name is null.
     */
    @Test(expected = VendingMachineException.class)
    public void testVendingMachineItem_NameNull()
    {
            VendingMachineItem tstVendingMachine = new VendingMachineItem(null, 2.50);   
    }



    /**
     * Test method for getName().
     */
    @Test
    public void testGetName()
    {
            VendingMachineItem tstVendingMachine = new VendingMachineItem("Item1", 1.00);
            VendingMachineItem tstVendingMachine1 = new VendingMachineItem("Item2", 1.25);

            assertEquals("Item1", tstVendingMachine.getName());
            assertEquals("Item2", tstVendingMachine1.getName());
    }



    /**
     * Test method for getPrice().
     */
    @Test
    public void testGetPrice()
    {
            VendingMachineItem tstVendingMachine = new VendingMachineItem("Item1", 1.00);
            VendingMachineItem tstVendingMachine1 = new VendingMachineItem("Item2", 1.25);

            assertEquals(1, tstVendingMachine.getPrice(), 0.001);
            assertEquals(1.25, tstVendingMachine1.getPrice(), 0.001);
    }

}
